<?php
    $action_url='C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module=spider'.AMP.'method=editCampaign';
    $changeUrl=$action_url;
    $action_url .='&campaignId='.$currentcampaignId;
    $hidden=array('tableName'=>'spider_campaign');

    function check($param, $data){
        if(array_search($param, unserialize($data[0]['api']))!==FALSE){
            return TRUE;
        }
        return FALSE;
    }
?>

<p class="go_notice"><?php echo $msg;?></p>
<?php  echo form_open($action_url, '',$hidden);?>
<table cellspacing="0" cellpadding="0" border="0" class="mainTable padTable">
    <thead>
        <tr>
            <th colspan="2">Edit campaign</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="2">
                <?php echo form_label("Select campaign", 'camapinId');?>
                <select name="campaign_id" onchange="location = '<?php echo BASE.AMP.$changeUrl.'&campaignId=';?>'+this.options[this.selectedIndex].value;">
                        <?php foreach ($campaigns as $campaign1):?>
                                <option value="<?php echo $campaign1['campaign_id'];?>" <?php if ($campaign1['campaign_id']==$currentcampaignId){echo 'selected="selected"';}?> ><?php echo $campaign1['campaign_name'];?></option>
                        <?php endforeach;?>
                </select>
            </td>
        </tr>
        <tr>
            <td width="40%">
                <strong>campaign Name</strong>
            </td>
            <td width="60%">
                <?php echo form_input($campaign);?>
                <?php echo form_error('campaign_name'); ?>
            </td>
        </tr>
        <tr>
            <td width="40%">
                <strong>Entries per run</strong>
            </td>
            <td width="60%">
                <?php echo form_input($noOfEntry);?>
                <?php echo form_error('no_of_entry'); ?>
            </td>
        </tr>
        <tr>
            <td width="40%">
                <strong>Chose Api for this campagin</strong>
            </td>
            <td width="60%">
                <?php foreach ($apiNames as $key=>$value):?>
                        <?php echo $value;?>
                        <?php echo form_checkbox('api[]', $key, check($key, $data));?>
                <?php endforeach;?>
                <?php echo form_error('api[]'); ?>
            </td>
        </tr>
        <tr>
            <td width="40%">
                <strong>Chose Channel</strong>
            </td>
            <td width="60%">
                <select name="channel_id">
                 <?php foreach ($channel_name as $weblog):?>
                        <option value="<?php echo $weblog['channel_id']; ?>" <?php if ($weblog['channel_id']==$data[0]['channel_id']){echo 'selected="selected"';}?>><?php echo $weblog['channel_title'];?></option>
                 <?php endforeach;?>
                 </select>
            </td>
        </tr>
        <tr>
            <td width="40%">
                <strong>Keywords for this campaign.(one per line)</strong>
            </td>
            <td width="60%">
                <?php echo form_textarea($keyword);?>
		<?php echo form_error('keyword'); ?>
            </td>
        </tr>
    </tbody>
</table>
<p><?php echo form_submit(array('name'=>'save', 'value'=>'Submit', 'class' => 'submit'));?></p>
